package datalookin.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.whu.zj.R;
import com.whu.zj.UIHandler;

import datalookin.fragment.HistoryFragment;
import datalookin.fragment.RealFragment;

/**
 * Created by Administrator on 2016/6/3.
 */
public class MainWaterActivity extends UIHandler.BaseActivity{
    private View v0;
    private View v1;

    private TextView tv1;
    private TextView tv2;

    // 水厂编号
    String waterPlantNum;
    // 水厂名称
    String waterPlantName;

    public String getWaterPlantNum() {
        return waterPlantNum;
    }

    public String getWaterPlantName() {
        return waterPlantName;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        waterPlantNum = getIntent().getStringExtra("waterPlantNum");
        waterPlantName = getIntent().getStringExtra("waterPlantName");

        setContentView(R.layout.activity_mainwater);
        initview();
        getSupportFragmentManager().beginTransaction().replace(R.id.content, new RealFragment(),RealFragment.class.getSimpleName()).commit();
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int color = getResources().getColor(R.color.bluelight);
            switch (v.getId()) {
                case R.id.id_realwater:
                    tv1.setTextColor(getResources().getColor(R.color.bluelight));
                    tv2.setTextColor(getResources().getColor(R.color.grey));

                    getSupportFragmentManager().beginTransaction().replace(R.id.content, new RealFragment(),RealFragment.class.getSimpleName()).commit();
                    break;
                case R.id.id_historywater:
                    tv2.setTextColor(getResources().getColor(R.color.bluelight));
                    tv1.setTextColor(getResources().getColor(R.color.grey));
                    getSupportFragmentManager().beginTransaction().replace(R.id.content, new HistoryFragment(),HistoryFragment.class.getSimpleName()).commit();
                    break;

            }
        }
    };

    private void initview() {
        v0 = findViewById(R.id.id_realwater);
        v1 = findViewById(R.id.id_historywater);
        v0.setOnClickListener(onClickListener);
        v1.setOnClickListener(onClickListener);

        tv1 = (TextView) findViewById(R.id.id_tv1);
        tv2 = (TextView) findViewById(R.id.id_tv2);
    }
}
